package com.menu;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.xml.namespace.QName;

import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.slayer.model.LMSBook;
import com.slayer.model.impl.LMSBookImpl;

/**
 * Portlet implementation class MenuPortlet
 */
public class MenuPortlet extends MVCPortlet {
 
	public void quickAdd(ActionRequest actionRequest,
			ActionResponse actionResponse) throws IOException, PortletException {

		String bookTitle = ParamUtil.getString(actionRequest, "bookTitle");
		String author = ParamUtil.getString(actionRequest, "author");
		
		LMSBook lmsBook = new LMSBookImpl();
		lmsBook.setBookTitle(bookTitle);
		lmsBook.setAuthor(author);
		
		PortletSession portletSession = actionRequest.getPortletSession();
		portletSession.setAttribute("SUCCESS_MSG", "the book added successfully...", PortletSession.APPLICATION_SCOPE);
				
		QName qName = new QName("http://liferay.com", "lmsBook", "x");
		actionResponse.setEvent(qName, lmsBook);
	}
}